package cn.jzx.hbase;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.*;
import org.apache.hadoop.hbase.util.Bytes;

public class GetDemo {
    public static void main(String[] args) throws Exception {
        Configuration config = HBaseConfiguration.create(); //获取链接信息
        //创建表
        //创建链接
        try (Connection connection = ConnectionFactory.createConnection(config)) {
            Admin admin = connection.getAdmin();
            System.out.println("get...... ");
            //do get
            Get get = new Get("row-0001".getBytes());
            //t.get t.put t.scan t.delete ....
            Table table = connection.getTable(TableName.valueOf("gamer"));
            Result result=table.get(get);
            // table(rows( cells))
            //result ---> row
            //result.getMap---> map(cf,columsMap)
            result.getMap().forEach((cf,map) ->{
                String family = Bytes.toString(cf);
                System.out.println("列族:"+family);
                map.forEach((qualifier,vmap)->{
                   String column = Bytes.toString(qualifier);
                    System.out.println("列:"+column);
                    vmap.forEach((ts,value)->{
                        System.out.println("时间戳版本:"+ts);
                        System.out.println("值:"+Bytes.toString(value));
                    });
                });
            });
            System.out.println(" Done.");

        }
    }
}
